﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Wicresoft.UnifyShow.Business;
using Microsoft.Practices.Unity;

namespace Wicresoft.UnifyShow.Portal.Controllers
{
    public class BESContentPartialViewController : BaseController
    {
        private IBusinessSystem businessSystem;
        private IDevice device;
        private IUser_X user;
        protected override void Dispose(bool disposing)
        {
            ((IDisposable)businessSystem).Dispose();
            ((IDisposable)device).Dispose();
            ((IDisposable)user).Dispose();
        }

        [InjectionConstructor]
        public BESContentPartialViewController(IBusinessSystem businessSystem, IDevice device,IUser_X user)
        {
            this.businessSystem = businessSystem;
            this.device = device;
            this.user = user;
        }

        public ActionResult ContentPartialView(int siteID, string serviceName)
        {
            base.SetRoles(user);
            if (!UserSiteIDs.Contains(decimal.Parse(siteID + ""))) return new HttpStatusCodeResult(403);

            var bSystem = businessSystem.GetBusinessSystemBySiteIdAndCName(siteID, serviceName);
            ViewData["ServiceID"] = bSystem.ID;
            ViewData["local"] = siteID;
            ViewData["bSystemVendorInfo"] = bSystem.VendorInfo;
            ViewData["listServers"] = device.GetServerBySiteIDBSIDWithAlert(siteID, bSystem.ID);
            ViewData["listMiddleWares"] = device.GetMiddleWareBySiteIDBSIDWithAlert(siteID, bSystem.ID);
            ViewData["listSQLServers"] = device.GetSQLServerBySiteIDBSIDWithAlert(siteID, bSystem.ID);
            return PartialView();
        }

        //public ActionResult ContentPartialView(int siteID, int serviceID)
        //{
        //    var bSystem = businessSystem.GetBusinessSystemByID(serviceID);
        //    ViewData["local"] = siteID;
        //    ViewData["bSystemVendorInfo"] = bSystem.VendorInfo;
        //    ViewData["listServers"] = device.GetServerBySiteIDBSIDWithAlert(siteID, serviceID);
        //    return PartialView();
        //}
    }
}
